package cn.com.czpb.client.module.subscribe.adapter;

import android.support.annotation.Nullable;
import android.view.View;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import cn.com.czpb.client.R;
import cn.com.czpb.client.model.subscribe.SubscribeListBean;

import java.util.List;

/**
 * Created by 猪猪侠 on 2017/7/31.
 */

public class SubscribeMoreAdapter extends BaseQuickAdapter<SubscribeListBean,BaseViewHolder> {

    private int selectedPosition =0;
    private List<SubscribeListBean> list;
    public SubscribeMoreAdapter(@Nullable List<SubscribeListBean> list) {
        super(R.layout.item_subscribemore_classify);
        this.list =list;
       selectedPosition =0;
    }

    @Override
    protected void convert(BaseViewHolder helper, SubscribeListBean item) {
        if (helper.getLayoutPosition()==selectedPosition) {
            helper.getView(R.id.line).setVisibility(View.VISIBLE);
        }else {
            helper.getView(R.id.line).setVisibility(View.GONE);
        }
        helper.getView(R.id.tv_classify_item).setSelected(selectedPosition==helper.getAdapterPosition());
        helper.setText(R.id.tv_classify_item,item.getName())
                .addOnClickListener(R.id.rl_root_id);
    }
    public void setPosition(int selectedPosition){
        this.selectedPosition = selectedPosition;
        notifyDataSetChanged();
    }
}
